class Solution {
public:
    int dayOfYear(string date) {
        unordered_map<int, int> map = { {1,31},{2,28},{3,31},{4,30},{5,31},{6,30},{7,31},{8,31},{9,30},{10,31},{11,30},{12,31} };
        string year;
        string month;
        string day;
        for (auto& e : date)
        {
            if (e == '-')
            {
                e = '+';
                break;
            }
            year += e;
            e = '+';
        }
        for (auto& e : date)
        {
            if (e == '+')
                continue;
            if (e == '-')
            {
                e = '+';
                break;
            }
            month += e;
            e = '+';
        }
        for (auto& e : date)
        {
            if (e == '+')
                continue;
            if (e == '-')
            {
                e = '+';
                break;
            }
            day += e;
            e = '+';
        }
        int _year = stoi(year);
        int _month = stoi(month);
        int _day = stoi(day);
        int count = 0;
        for (int i = 1; i < _month; i++)
        {
            if (i == 2 && ((_year % 4 == 0 && _year % 100 != 0) || (_year % 400 == 0)))
            {
                count += 29;
                continue;
            }
            count += map[i];
        }
        count += _day;
        return count;
    }
};